/**
  * @file: Terrain.h
  * @author: Adrian Johnston and Steven Hobson-Campbell
  */


#ifndef TERRAIN_H_
#define TERRAIN_H_

#include <GL/glew.h>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <cmath>
#include <list>
#include "GrassCluster.h"
#include "Structures.h"

class Terrain {
public:
    Terrain(std::string hmFilename, GLuint shaderProg);
    ~Terrain();
    void load();	//Will load the terrain into a VBO
    void setScale(GLfloat x, GLfloat y, GLfloat z);
    void render(vec3 camPos); //Will render the terrain
    std::string getHMFileName(); //Returns the path to the current filename
    GLfloat* getHeightmap();
    GLuint getWidth();
    GLuint getHeight();
    vec3 getScale();
private:
   // Grass *grass;
   // GrassCluster *grassCluster;
    std::vector<GrassCluster*> grassList;
    GLuint shaderProg;
    sf::Image heightMap;
    sf::Image texture;
    sf::Image splatMap;
    std::string filename;
    GLuint splatID;
	GLuint dirtID;
    GLuint grassID;
    GLuint sandID;
	GLuint rockID;
    GLboolean imageLoaded; //Prevent rendering before loading
    Vertex *vertices;
    std::list<Normal*> *normalsByPosition;
    GLuint *indices;
    GLuint vboID;
    GLuint indicesVBOID;
    GLuint noIndices;
    GLuint numVertices;
    GLuint width;
    GLuint height;
    GLfloat xScale;
    GLfloat yScale;
    GLfloat zScale;
    GLfloat *terrainHeight;
};
#endif /* TERRAIN_H_ */
